//
//  UIButton + Extension.swift
//  1026SwiftSinaWeiBo
//
//  Created by Apple on 15/11/1.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit

extension UIButton {

    //便利构造函数  并设置默认属性
    convenience init(imageName: String, title: String, titleColor: UIColor = UIColor.lightGrayColor(), fontSize: CGFloat = 14) {
    
        self.init()
        
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setTitle(title, forState: UIControlState.Normal)
        setTitleColor(titleColor, forState: UIControlState.Normal)
        
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
    }
    
    
    //便利构造函数  并设置默认属性
    convenience init(bkgImageName: String = "health_button_orange_line", title: String, titleColor: UIColor = UIColor.whiteColor(), fontSize: CGFloat = 18) {
        
        self.init()
        
        setBackgroundImage(UIImage(named: bkgImageName), forState: UIControlState.Normal)
        
        let bkgImageNameH = bkgImageName + "_highlighted"
        
        setBackgroundImage(UIImage(named: bkgImageNameH), forState: UIControlState.Highlighted)
        
        setTitle(title, forState: UIControlState.Normal)
        setTitleColor(titleColor, forState: UIControlState.Normal)
        
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
    }

}
